//
//  ClearSetting.swift
//  YoruNeko
//
//  Created by Kotori on 2021/6/21.
//

import SwiftUI

struct HistorySetting: View {
    @State var isNoHistory: Bool = false
    let currUserMgr = UserManager.currUserMgr
    
    var body: some View {
        List {
            Toggle("无痕浏览模式", isOn:$isNoHistory)
                .onChange(of: isNoHistory, perform: { isNo in
                    currUserMgr.setNoHistory(isNo: isNo)
                })
        }
        .onAppear {
            isNoHistory = currUserMgr.getNoHistory()
        }
        .onDisappear(perform: {
            currUserMgr.commit()
        })
    }
}

struct HistorySetting_Previews: PreviewProvider {
    static var previews: some View {
        HistorySetting()
    }
}
